import request from './request'

// 获取部门列表
export const getDepartmentList = (params) => {
  return request({
    url: '/departments',
    method: 'get',
    params
  })
}

// 获取部门树形结构
export const getDepartmentTree = () => {
  return request({
    url: '/departments/tree',
    method: 'get'
  })
}

// 获取单个部门信息
export const getDepartmentInfo = (id) => {
  return request({
    url: `/departments/info/${id}`,
    method: 'get'
  })
}

// 创建部门
export const createDepartment = (data) => {
  return request({
    url: '/departments',
    method: 'post',
    data
  })
}

// 更新部门信息
export const updateDepartment = (id, data) => {
  return request({
    url: `/departments/${id}`,
    method: 'put',
    data
  })
}

// 删除部门
export const deleteDepartment = (id) => {
  return request({
    url: `/departments/${id}`,
    method: 'delete'
  })
}